home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / music / cthugha5.zip / CTHU5SRC.ZIP / ENVIRON.C < prev    next >
C/C++ Source or Header  |  1994-08-19  |  1KB  |  64 lines

  1. //
  2. // Cthugha - Audio Seeded Image Processing
  3. //
  4. // Zaph, Digital Aasvogel Group, Torps Productions 1993-1994
  5. //
  6.  
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #include <ctype.h>
  11. #include "sb.h"
  12.  
  13. unsigned SbIOaddr;
  14. unsigned SbIRQ;
  15. unsigned SbDMAchan;
  16. int SbType;
  17.  
  18. int Sb_Get_Params(void)
  19. {
  20.     char *t, *t1, *blaster;
  21.  
  22.     /* Set arguments to reasonable values (Soundblaster defaults) */
  23.     SbIOaddr = 0x220;
  24.     SbIRQ = 7;
  25.     SbDMAchan = 1;
  26.  
  27.     /* Attempt to read environment variable */
  28.     t = getenv("BLASTER");
  29.  
  30.     /* Is the environment variable set? */
  31.     if(t == NULL)
  32.     return 1;
  33.  
  34.     /* Duplicate the string so that we don't trash our environment */
  35.     blaster = strdup(t);
  36.  
  37.     /* Now parse the BLASTER variable */
  38.     t = strtok(blaster," \t");
  39.     while(t)
  40.     {
  41.     switch(toupper(t[0]))
  42.     {
  43.         case 'A':                               /* I/O address */
  44.         SbIOaddr = (int)strtol(t+1,&t1,16);
  45.         break;
  46.         case 'I':                               /* Hardware IRQ */
  47.         SbIRQ = atoi(t+1);
  48.         break;
  49.         case 'D':                               /* DMA channel */
  50.         SbDMAchan = atoi(t+1);
  51.         break;
  52.         case 'T':                               /* Soundblaster type */
  53.         SbType = atoi(t+1);
  54.         break;
  55.         default:
  56.         printf("Unknown BLASTER option %c\n",t[0]);
  57.         break;
  58.     }
  59.     t = strtok(NULL," \t");
  60.     }
  61.     free(blaster);
  62.     return 0;
  63. }
  64.